<template>
    <div>
        <div class="main-panel">
            <div class="menus">
                <div v-for="menu in menus" :key="menu.name" @click="topage(menu)">
                    {{ menu.name }}
                </div>
            </div>

            <div class="router-view-container">
                <router-view></router-view>
            </div>
        </div>
        <div class="title">BLOG后台管理</div>
    </div>
</template>

<script setup>
import { ref, reactive, inject } from "vue";
import { useRouter, useRoute } from "vue-router";
import { AdminStore } from "../../stores/AdminStore";
const router = useRouter()
const route = useRoute()

const axios = inject('axios')
const message = inject('message')

const adminStore = AdminStore()

let menus = [
    { name: "文章管理", href: "/dashboard/article" },
    { name: "分类管理", href: "/dashboard/category" },
    { name: "退出", href: "logout" },
];

const topage = (menu) => {
    if (menu.href == "logout") {
        router.push("/login")
        localStorage.removeItem("token")
    } else {
        router.push(menu.href)
    }
}
</script>

<style lang="scss" scoped>
.main-panel {
    display: flex;
    color: #444;
    max-width: 1500px;
    margin: 0 auto;

    .menus {
        padding: 20px 0;
        width: 180px;
        height: 100vh;
        border-right: 1px solid #ccc;
        text-align: center;
        line-height: 55px;
        box-sizing: border-box;
        font-weight: 600;

        div {
            cursor: pointer;

            &:hover {
                color: peru;
            }
        }

    }

    .router-view-container {
        width: 100vw;
        height: 100vh;
    }
}

.title {
    position: fixed;
    right: 0;
    bottom: 0;
    font-weight: 600;
    font-size: 34px;
    color: rgba(238, 238, 238, .6);
    pointer-events: none; // 点击事件会穿透该元素
    // z-index: -100;
    // background: transparent;
}
</style>